package com.sl.au.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import com.sl.au.entity.AfterSaleOutHouseView;
import com.sl.au.repository.AfterSaleOutHouseViewRepository;
import com.sl.au.service.AfterSaleOutHouseViewService;

@Service("AfterSaleOutHouseViewService")
public class AfterSaleOutHouseViewServiceImpl extends BaseServiceImpl implements AfterSaleOutHouseViewService {

	@Autowired
	AfterSaleOutHouseViewRepository afterSaleOutHouseViewRepository;
	@Override
	public AfterSaleOutHouseViewRepository getRepository() {
		// TODO Auto-generated method stub
		return this.afterSaleOutHouseViewRepository;
	}
	
	@Override
	public List<AfterSaleOutHouseView> getAllOutHouseTicket(int start, int length, Map<String, String> condition,
			String orderName, String dir) {
		Page<AfterSaleOutHouseView> pages = null;
		Pageable pageable = new PageRequest(start / length, length, Sort.Direction.DESC, "createTime");
		pages = afterSaleOutHouseViewRepository.getAllOutHouseTicket(condition.get("key"), pageable);
		return pages.getContent();
	}

	@Override
	public List<AfterSaleOutHouseView> getYesOutHouseTicket(int start, int length, Map<String, String> condition,
			String orderName, String dir) {
		Page<AfterSaleOutHouseView> pages = null;
		Pageable pageable = new PageRequest(start / length, length, Sort.Direction.DESC, "createTime");
		pages = afterSaleOutHouseViewRepository.getYesOutHouseTicket(condition.get("key"), pageable);
		return pages.getContent();
	}

	@Override
	public List<AfterSaleOutHouseView> getNoOutHouseTicket(int start, int length, Map<String, String> condition,
			String orderName, String dir) {
		Page<AfterSaleOutHouseView> pages = null;
		Pageable pageable = new PageRequest(start / length, length, Sort.Direction.DESC, "createTime");
		pages = afterSaleOutHouseViewRepository.getNoOutHouseTicket(condition.get("key"), pageable);
		return pages.getContent();
	}


}
